import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CategoryVO, CategoryForm, CategoryQuery, CarmiFormat } from '@/api/workflow/category/types';

/**
 * 查询流程分类列表
 * @param query
 * @returns {*}
 */

export const listCategory = (query?: CategoryQuery): AxiosPromise<CategoryVO[]> => {
  return request({
    url: '/system/category/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询流程分类详细
 * @param id
 */
export const getCategory = (id: string | number): AxiosPromise<CategoryVO> => {
  return request({
    url: '/system/category/' + id,
    method: 'get'
  });
};

/**
 * 新增流程分类
 * @param data
 */
export const addCategory = (data: CategoryForm) => {
  return request({
    url: '/system/category',
    method: 'post',
    data: data
  });
};

/**
 * 修改流程分类
 * @param data
 */
export const updateCategory = (data: CategoryForm) => {
  return request({
    url: '/system/category',
    method: 'put',
    data: data
  });
};

/**
 * 删除流程分类
 * @param id
 */
export const delCategory = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/category/' + id,
    method: 'delete'
  });
};
// 获取卡密下的球队或者球员 1:球队 2:球员 3:根据球员跟球队
// /collage/getCarmiGroupByType?cardCategoryId=&type=&cardTeamId=1&playerId=1
export const getCarmiGroupByType = (query: any) => {
  return request({
    url: '/system/collage/getCarmiGroupByType',
    method: 'get',
    params: query
  });
};

export const queryCardCaCtegoryBySeries = (query: any) => {
  return request({
    url: '/system/collage/queryCardCaCtegoryBySeries',
    method: 'get',
    params: query
  });
};

// /collage/queryCardCaCtegoryType?series=&pageSize=1&pageNum=1&orderByColumn=&isAsc=
export const queryCardCaCtegoryType = (query: any) => {
  return request({
    url: '/system/collage/queryCardCaCtegoryType',
    method: 'get',
    params: query
  });
};
// /collage/queryCardCategoryByName?series=&subSeries=&name=&pageSize=1&pageNum=1&orderByColumn=&isAsc=
export const queryCardCategoryByName = (query: any) => {
  return request({
    url: '/system/collage/queryCardCategoryByName',
    method: 'get',
    params: query,
  });
};

export const previewCard = (query?: any): AxiosPromise<CarmiFormat[]> => {
  return request({
    url: '/system/collage/preview',
    method: 'post',
    params: query,
    headers: {
      isEncrypt: true
    },
  });
};

